import xlrd, os


def analyze_xls(file_name, sheet_name):
    xls_file = xlrd.open_workbook("." + os.sep + "data" + os.sep + file_name)

    # 获取表格的sheet
    sheet = xls_file.sheet_by_name(sheet_name)

    # 获取一行元素个数rows_num的和一列元素个数cols_num
    rows_num = len(sheet.row_values(0))
    cols_num = len(sheet.col_values(0))

    data_result = []

    for row in range(cols_num):
        tupe_tmp = []
        for col in range(rows_num):
            tupe_tmp.append(sheet.cell(row, col).value)
        data_result.append(tuple(tupe_tmp))
    print(data_result[0], data_result[1:])
    return data_result[0], data_result[1:]


"""
import xlrd

wb = xlrd.open_workbook("F:/csv.xls")
sh = wb.sheet_by_index(0)  # 第一个表
rowName = sh.row_values(0)#读取一行的数据
colName = sh.col_values(0)#读取一列的数据
row = len(colName)#读取行数
col = len(rowName)#读取列数
valu = sh.cell(1,0).value#获取某个单元格的值
print(row)
print(col)
print(valu)
for name in colName:
    print(name)
"""